package two;

import java.util.*;

public class demo3 {
    public static void main(String[] args) {

        Map<Integer, Map<String, Integer>> map = new HashMap<>();

        Random random = new Random();

        int userNum = 500;
        int bookNum = 3000;
        int userRateNum = 1000;

        for (int i = 0; i < userNum; i++) {
            Map<String, Integer> rateMap = new HashMap<>();
            int nowUserRateNum = random.nextInt(userRateNum);
            for (int j = 0; j < nowUserRateNum; j++) {
                rateMap.put("book"+random.nextInt(bookNum), random.nextInt(10));
            }
            map.put(i, rateMap);
        }

        BookRecommendationSystem2 bookSystem =
                new BookRecommendationSystem2(map);

        System.out.println("用户评价的图书");
        //for (int i = 0; i < map.size(); i++) {
        for (int i = 0; i < 10; i++) {
            int i1 = random.nextInt(map.size());
            System.out.println("第"+ i1 + "位用户 评价了 " + map.get(i1).size() + " 本");
            for(Map.Entry<String, Integer> entry:map.get(i1).entrySet()){
                System.out.println(entry.getKey()+" "+entry.getValue());
            }
        }
        //for (int i = 0; i < userNum; i++) {
        for (int i = 0; i < 20; i++) {
            int i1 = random.nextInt(map.size());
            List<String> strings = bookSystem.recommendBooks(i1);

            System.out.println("为用户 "+ i1 + " 推荐的图书");
            System.out.println(strings.size());
            strings.stream().limit(20).forEach(System.out::println);
        }
    }
}
